﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using FrameworkLib.Utilities.CustomTypeDescriptor;

namespace GestionePolveriLib.BL.Reports
{
    public class ReportDirezionaleTotali
    {
        private double? m_giacenzaXValore = 0;

        [Browsable(false)]
        [ReadOnly(true)]
        public string Tag { get; set; }

        [Browsable(false)]
        public bool UseCalculatedField { get; set; }

        [DisplayName("Totale Prelievi")]
        [Browsable(false)]
        [ReadOnly(true)]
        public int NumeroPrelieviTot { get; set; }



        /* -- */
        [Id(1, 1)]
        [DisplayName("Tipo")]
        [Browsable(true)]
        [ReadOnly(true)]
        public string Applicazione { get; set; }

        [Id(2, 1)]
        [DisplayName("Codice Polvere")]
        [Browsable(true)]
        [ReadOnly(true)]
        public string CodicePolvere { get; set; }

        [Id(3, 1)]
        [DisplayName("Note Polvere")]
        [Browsable(true)]
        [ReadOnly(true)]
        public string Note { get; set; }

        [Id(4, 1)]
        [DisplayName("Famiglia")]
        [Browsable(true)]
        [ReadOnly(true)]
        public string Famiglia { get; set; }

        [Id(5, 1)]
        [DisplayName("Descrizione")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public string Descrizione { get; set; }

        [Id(6, 1)]
        [DisplayName("Fornitore")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public string Fornitore { get; set; }

        [Id(7, 1)]
        [DisplayName("ColoriAbbinati")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public string ColoriAbbinati { get; set; }

        [Id(8, 1)]
        [DisplayName("ScortaMinima")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public double ScortaMinima { get; set; }

        [Id(9, 1)]
        [DisplayName("Ultimo Prezzo")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public double? PrezzoUnitario { get; set; }

        [Id(10, 1)]
        [DisplayName("Giacenza")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public double? Giacenza { get; set; }

        [Id(11, 1)]
        [DisplayName("Euro")]
        [Browsable(true)]
        [ReadOnly(true)]
        public double? GiacenzaXValore
        {
            set { m_giacenzaXValore = value; }
            get
            {
                if (UseCalculatedField)
                    m_giacenzaXValore = Giacenza * PrezzoUnitario;

                return m_giacenzaXValore;
            }
        }

        [Id(12, 1)]
        [DisplayName("Carico")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public double? Carico { get; set; }

        [Id(13, 1)]
        [DisplayName("Scarico")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public double? Scarico { get; set; }

        [Id(14, 1)]
        [DisplayName("Numero Prelievi")]
        [Browsable(true)]
        [ReadOnly(true)]
        public double? NumeroPrelievi
        {
            get
            {
                return this.NP_AllineamentoInventatio.GetValueOrDefault(0) +
                       this.NP_ColorwoodGrande.GetValueOrDefault(0) +
                       this.NP_ColorwoodPiccolo.GetValueOrDefault(0) +
                       this.NP_Ferro.GetValueOrDefault(0) +
                       this.NP_RAL1.GetValueOrDefault(0) +
                       this.NP_RAL2.GetValueOrDefault(0) +
                       this.NP_Reso.GetValueOrDefault(0) +
                       this.NP_Smaltito.GetValueOrDefault(0) +
                       this.NP_Sublimato.GetValueOrDefault(0) +
                       this.NP_Venduto.GetValueOrDefault(0) +
                       this.NP_Verticale.GetValueOrDefault(0);
            }
        }

        [Id(15, 1)]
        [DisplayName("RAL1 Kg.")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public double? Cons_RAL1 { get; set; }

        [Id(16, 1)]
        [DisplayName("RAL1 Np.")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public double? NP_RAL1 { get; set; }

        [Id(17, 1)]
        [DisplayName("RAL2 Kg.")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public double? Cons_RAL2 { get; set; }

        [Id(18, 1)]
        [DisplayName("RAL2 Np.")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public double? NP_RAL2 { get; set; }

        [Id(19, 1)]
        [DisplayName("Verticale Kg.")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public double? Cons_Verticale { get; set; }

        [Id(20, 1)]
        [DisplayName("Verticale Np.")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public double? NP_Verticale { get; set; }

        [Id(21, 1)]
        [DisplayName("Ferro Kg.")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public double? Cons_Ferro { get; set; }

        [Id(22, 1)]
        [DisplayName("Ferro Np.")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public double? NP_Ferro { get; set; }

        [Id(23, 1)]
        [DisplayName("ColorwoodGrande Kg.")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public double? Cons_ColorwoodGrande { get; set; }

        [Id(24, 1)]
        [DisplayName("ColorwoodGrande Np.")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public double? NP_ColorwoodGrande { get; set; }

        [Id(25, 1)]
        [DisplayName("ColorwoodPiccolo Kg.")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public double? Cons_ColorwoodPiccolo { get; set; }

        [Id(26, 1)]
        [DisplayName("ColorwoodPiccolo Np.")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public double? NP_ColorwoodPiccolo { get; set; }

        [Id(27, 1)]
        [DisplayName("Reso Kg.")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public double? Cons_Reso { get; set; }

        [Id(28, 1)]
        [DisplayName("Reso Np.")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public double? NP_Reso { get; set; }

        [Id(29, 1)]
        [DisplayName("Smaltito Kg.")]
        [Browsable(true)]
        [ReadOnly(true)]
        public double? Cons_Smaltito { get; set; }

        [Id(30, 1)]
        [DisplayName("Smaltito Np.")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public double? NP_Smaltito { get; set; }

        [Id(31, 1)]
        [DisplayName("Sublimato Kg.")]
        [Browsable(true)]
        [ReadOnly(true)]       
        public double? Cons_Sublimato { get; set; }

        [Id(32, 1)]
        [DisplayName("Sublimato Np.")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public double? NP_Sublimato { get; set; }

        [Id(33, 1)]
        [DisplayName("Venduto Kg.")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public double? Cons_Venduto { get; set; }

        [Id(34, 1)]
        [DisplayName("Venduto Np.")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public double? NP_Venduto { get; set; }

        [Id(35, 1)]
        [DisplayName("Correzione Kg.")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public double? Cons_Correzione { get; set; }

        [Id(36, 1)]
        [DisplayName("Correzione Np.")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public double? NP_Correzione { get; set; }

        [Id(37, 1)]
        [DisplayName("Allineamento Inventario Kg.")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public double? Cons_AllineamentoInventario { get; set; }

        [Id(38, 1)]
        [DisplayName("Allineamento Inventario Np.")]
        [Browsable(true)]
        [ReadOnly(true)]        
        public double? NP_AllineamentoInventatio { get; set; }

        public ReportDirezionaleTotali()
        {
        }

        public ReportDirezionaleTotali(GestionePolveriLib.BL.Reports.ReportDirezionale totali)
        {
            this.Applicazione = totali.Applicazione;
            this.Carico = totali.Carico;
            this.CodicePolvere = totali.CodicePolvere;
            this.ColoriAbbinati = totali.ColoriAbbinati;
            this.Cons_AllineamentoInventario = totali.Cons_AllineamentoInventario;
            this.Cons_ColorwoodGrande = totali.Cons_ColorwoodGrande;
            this.Cons_ColorwoodPiccolo = totali.Cons_ColorwoodPiccolo;
            this.Cons_Correzione = totali.Cons_Correzione;
            this.Cons_Ferro = totali.Cons_Ferro;
            this.Cons_RAL1 = totali.Cons_RAL1;
            this.Cons_RAL2 = totali.Cons_RAL2;
            this.Cons_Reso = totali.Cons_Reso;
            this.Cons_Smaltito = totali.Cons_Smaltito;
            this.Cons_Sublimato = totali.Cons_Sublimato;
            this.Cons_Venduto = totali.Cons_Venduto;
            this.Cons_Verticale = totali.Cons_Verticale;
            this.Descrizione = totali.Descrizione;
            this.Famiglia = totali.Famiglia;
            this.Fornitore = totali.Fornitore;
            this.Giacenza = totali.Giacenza;
            this.GiacenzaXValore = totali.GiacenzaXValore;
            this.Note = totali.Note;
            this.NP_AllineamentoInventatio = totali.NP_AllineamentoInventario;
            this.NP_ColorwoodGrande = totali.NP_ColorwoodGrande;
            this.NP_ColorwoodPiccolo = totali.NP_ColorwoodPiccolo;
            this.NP_Correzione = totali.NP_Correzione;
            this.NP_Ferro = totali.NP_Ferro;
            this.NP_RAL1 = totali.NP_RAL1;
            this.NP_RAL2 = totali.NP_RAL2;
            this.NP_Reso = totali.NP_Reso;
            this.NP_Smaltito = totali.NP_Smaltito;
            this.NP_Sublimato = totali.NP_Sublimato;
            this.NP_Venduto = totali.NP_Venduto;
            this.NP_Verticale = totali.NP_Verticale;
            this.NumeroPrelieviTot = totali.NumeroPrelieviTot;
            this.PrezzoUnitario = totali.PrezzoUnitario;
            this.Scarico = totali.Scarico;
            this.ScortaMinima = totali.ScortaMinima;
            this.Tag = totali.Tag;
            this.UseCalculatedField = totali.UseCalculatedField;
        }
    }
}
